#include <REGX52.H>
#include "Key.h"
#include "Delay.h"
#include "Timer0.h"
#include "UART.h"
#include "Nixie.h"
	unsigned char Miao = 0;
	unsigned char Fen = 0;
	unsigned char Shi = 0;
	unsigned char Anjian=0;
	unsigned char Moshi=0;
void main()
{
	UART_Init();
	Timer0Init();
	while(1)
	{
		Nixie(1,Shi/10);
		Nixie(2,Shi%10);
		Nixie(3,16);
		Nixie(4,Fen/10);
		Nixie(5,Fen%10);
		Nixie(6,16);
		Nixie(7,Miao/10);
		Nixie(8,Miao%10);
		Anjian=Key();
		if(Anjian)
		{
			if(Anjian==1)
			{
				EA=~EA;
			}
			if(Anjian==2)
			{
				Miao++;
			}
			if(Anjian==3)
			{
				Fen++;
			}
			if(Anjian==4)
			{	
				Shi++;
			}
		}
//		UART_byte('s');
//		UART_byte(Shi);
//		//Delay(1000);
//		UART_byte('f');
//		UART_byte(Fen);
//		//Delay(1000);
//		UART_byte('m');
//		UART_byte(Miao);
//		Delay(1000);
	}
}




void Int0_Rountine(void) interrupt 1
{
	static unsigned int a=0;
	TH0=(65535-1000)/256;
	TL0=(65535-1000)%256+1;
	
	a++;
	if(a>=1000)
	{
		a=0;
		Miao++;
		if(Miao>=60)
		{
			Miao=0;
			Fen++;
			if(Fen>=60)
			{
				Fen=0;
				Shi++;
			}
		}
		UART_byte(Shi);
		UART_byte(Fen);
		UART_byte(Miao);
	}
}